//
// GPSMapEdit
// (c) Konstantin Galichsky (kg@geopainting.com), 2005
//
// The helper to fill editbox with file content.
//

# include "StdAfx.h"
# include "TransparentWnd.h"

	//
	// NOTE: these macros are defined in WinUser.h for Windows >= 5.0
	//
# ifndef WS_EX_LAYERED
	# define WS_EX_LAYERED 0x00080000
# endif
# ifndef LWA_ALPHA
	# define LWA_ALPHA     0x00000002
# endif

typedef WINUSERAPI BOOL (WINAPI * pfSetLayeredWindowAttributes_t) (HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);

void SetTransparent (HWND _hWnd, BYTE _btAlpha) {
	const HMODULE hUser32 = ::GetModuleHandle (_T ("User32.dll"));
	const pfSetLayeredWindowAttributes_t pfSetLayeredWindowAttributes = (pfSetLayeredWindowAttributes_t) ::GetProcAddress (hUser32, "SetLayeredWindowAttributes");
	if (pfSetLayeredWindowAttributes == NULL)
		return;

	::SetWindowLong (_hWnd, GWL_EXSTYLE, WS_EX_LAYERED | ::GetWindowLong (_hWnd, GWL_EXSTYLE));
	pfSetLayeredWindowAttributes (_hWnd, 1, _btAlpha, LWA_ALPHA);
}

